package top.jacktgq.sxt.bio.demo1;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author CandyWall
 * @Date 2019/10/20--16:10
 * @Description 定位一个节点
 */
public class IPTest {
    public static void main(String[] args) throws UnknownHostException {
        //使用getLocalHost方法创建InetAddress对象
        InetAddress address = InetAddress.getLocalHost();
        System.out.println(address.getHostAddress());
        System.out.println(address.getHostName());
        //根据域名得到InetAddress对象
        InetAddress addr = InetAddress.getByName("www.jacktgq.top");
        System.out.println(addr.getHostAddress());
        System.out.println(addr.getHostName());
    }
}
